<?php
class CmsUserModel extends CmsBaseUserModel
{
    protected $sessionName = 'cms_user';

    protected static $instance;

    public static function GetInstance()
    {
        return self::$instance ? self::$instance : self::$instance = new CmsUserModel();
    }

    public function Register($user)
    {
        $user['group_id'] = 'user';
        $this->CheckUrl($item['website']);
        return parent::Register($user);
    }

    protected function LoadFields()
    {
        parent::LoadFields();
        $this->SetForeignKey('group_id', AclGroupModel::GetInstance()->GetTableName(), 'id');
    }

    public function CreateRandomPassword()
    {
        $chars = "abcdefghijkmnopqrstuvwxyz023456789";
        srand((double)microtime()*1000000);
        $i = 0;
        $pass = '' ;
        while ($i <= 7) {
            $num = rand() % 33;
            $tmp = substr($chars, $num, 1);
            $pass = $pass . $tmp;
            $i++;
        }
        return $pass;
    }
}
?>